package com.ziyun.erp.web.modules.goodsProductCopyNew;

import java.util.Arrays;
import java.util.Map;

import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ziyun.erp.modules.goodsProductCopyNew.entity.GoodsProductCopyNewEntity;
import com.ziyun.erp.modules.goodsProductCopyNew.service.GoodsProductCopyNewService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 产品迁移临时表
 *
 * @author xueqz
 * @email 
 * @date 2018-10-15 11:51:43
 */
@RestController
@RequestMapping("goodsProductCopyNew/goodsproductcopynew")
public class GoodsProductCopyNewController {
    @Autowired
    private GoodsProductCopyNewService goodsProductCopyNewService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("goodsProductCopyNew:goodsproductcopynew:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = goodsProductCopyNewService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{productId}")
    @RequiresPermissions("goodsProductCopyNew:goodsproductcopynew:info")
    public R info(@PathVariable("productId") Integer productId){
        GoodsProductCopyNewEntity goodsProductCopyNew = goodsProductCopyNewService.selectById(productId);

        return R.ok().put("goodsProductCopyNew", goodsProductCopyNew);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("goodsProductCopyNew:goodsproductcopynew:save")
    public R save(@RequestBody GoodsProductCopyNewEntity goodsProductCopyNew){
        goodsProductCopyNewService.insert(goodsProductCopyNew);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("goodsProductCopyNew:goodsproductcopynew:update")
    public R update(@RequestBody GoodsProductCopyNewEntity goodsProductCopyNew){
        ValidatorUtils.validateEntity(goodsProductCopyNew);
        goodsProductCopyNewService.updateAllColumnById(goodsProductCopyNew);//全部更新
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("goodsProductCopyNew:goodsproductcopynew:delete")
    public R delete(@RequestBody Integer[] productIds){
        goodsProductCopyNewService.deleteBatchIds(Arrays.asList(productIds));

        return R.ok();
    }

}
